The present invention relates to an apparatus and a method of encoding moving picture signals. Particularly, this invention relates to an apparatus and a method of encoding moving picture signals with code amount control for real time variable-bit rate encoding.
Moving picture Experts Group (MPEG)-2 has been established as the international standards for encoding moving picture signals, such as, TV signals.
MPEG-2 offers motion-compensated prediction and transform encoding as its two technical features.
Motion-Compensated Prediction: A frame of moving picture is divided into 16xc3x9716 blocks called macroblocks. For each macroblock, a motion amount called a motion vector is detected between the present picture frame to be coded and a reference frame which comes before or after the present picture frame on the time base by a predetermined number of frames. An encoded picture is generated on the basis of the reference frame and the motion vector.
Transform Encoding: A picture frame or a predictive error signal generated by motion-compensated prediction is compressed by Discrete Cosine Transform (DCT) as an orthogonal transforming technique.
Motion-compensated prediction in MPEG-2 generates moving pictures of three types; I-pictures (intra-coded pictures), P-pictures (predictive-coded pictures) and B-pictures (bidirectionally predictive-coded pictures).
I-pictures are subjected to DCT as they are, on the other hand, for P- and B-pictures, predictive error signals are subjected to DCT, for generating DCT coefficients.
The DCT coefficients are quantized with a quantization scale factor under code amount control.
The quantized DCT coefficients are encoded by variable-length encoding, with auxiliary data, such as, motion vectors, to generate a bit stream which will be an output coded data via buffer.
A quantization scale factor is determined by code amount control according to the amount of bit stream passing through the buffer.
The quantized DCT coefficients are further subjected to de-quantization and Inverse-DCT (IDCT) for local decoding, and stored in a frame memory per macroblock for motion-compensated prediction.
The amount of codes (bit rate) generated for each predetermined period in MPEG-2 is not constant due to variable-length encoding.
In order to overcome this problem, MPEG-2 has offered techniques of quantization scale factor adjustments per macroblock for achieving constant bit rate.
MPEG-2 Test Model 5 has proposed a technique of constant bit rate control for generating a constant amount of codes per Group of Pictures (GOP), for achieving constant transfer rate.
This technique, however, allocates almost the same amount of codes over the entire portions of a moving picture sequence. The constant amount code allocation causes deterioration of images due to insufficient code allocation to images of complex scenes which have a lot of data, on the other hand, unnecessary code amount allocation to images of plain scenes which have a few data.
This technique is, therefore, not a suitable bit rate control method for DVD-Video having a variable-transfer rate control function, for instance.
A technique of variable-bit rate control overcomes the problem of constant bit rate control for DVD-Videos, and is disclosed in Japanese Unexamined-Patent Publication No. 1994(6)-141298.
In this technique, an input moving picture is subjected to temporal (first) encoding with a fixed quantization scale factor, and the amount of generated codes is counted per specific period of time. A target transfer rate for each portion, such as, a frame, of the input moving picture is set on the basis of the counted code amount so that the amount of codes of the entire input moving picture becomes a specific value.
The input moving picture is then subjected to actual (second) encoding with bit rate adjustments so that a bit rate for each portion of the input moving picture becomes the target transfer rate.
This variable-bit rate control, however, requires two time-encoding, that is, temporal and actual encoding, thus not achieving real time control. The two time-encoding is called two pass-encoding hereinafter.
Contrary to such two pass-encoding, one pass (time)-encoding with variable-bit rate control has been introduced by Japanese Unexamined-Patent Publication No. 1998(10)-164577 for almost real time moving picture encoding.
This technique obtains picture complexity calculated by multiplying the amount of codes encoded so far and an average quantization scale factor for each picture. The ratio of the present picture complexity to average past picture complexity is used for deciding a target code amount or target quantization scale factor for variable-bit rate control.
Another technique of one pass-encoding with variable-bit rate control is disclosed in Unexamined-Patent Publication No. 1998(10)-302396.
This technique examines difficulty in encoding per predetermined period for obtaining a temporal code amount to be allocated for each predetermined period with reference to a standard encoding difficulty and code amount to be allocated.
The temporal code amount to be allocated is changed to an actual code amount to be allocated by comparing a code amount to be allocated Bav which is given by encoding with a fixed code amount to be allocated bav decided under actual storage capacity of a storage medium and a total actual code amount Bgen encoded so far; and allowing a code amount to be allocated equal to or larger than bav when Bavxe2x80x94bav is positive, thus achieving recording of a certain length of moving picture on a storage medium so that a total code amount generated for the certain length of moving picture is smaller than the storage capacity of the storage medium.
This one pass-encoding with variable-bit rate control also has the following disadvantages:
In this technique, the present picture complexity is obtained by temporarily encoding the present picture which will be encoded from now on or the picture complexity of the picture encoded just before and of the same picture-type is used as the present picture complexity without temporal encoding.
The one pass-encoding thus causes delay in encoding if it is temporal encoding and requires a bulk of circuitry.
Moreover, even though without such temporal encoding, when picture complexity varies on pictures, in other words, scene change occurs just before the present picture to be encoded, the picture complexity decided just before (the same picture-type) used as the present picture complexity would be different from actual picture complexity. This causes improper code amount allocation.
Different from the two pass-encoding, the one passencoding executes bit rate control without detecting how picture complexity varies for an input moving picture sequence.
This technique thus executes encoding under assumption that overall change in picture complexity of an input moving picture sequence is similar to that of average picture complexity of typical pictures.
This also causes improper code amount allocation, for example, for a moving picture sequence with monotonic increase in picture complexity (for example, the former part of the moving picture sequence is constituted by simple scenes easy for encoding and the latter part gradually complex scenes hard for encoding).
Code amounts to be allocated for such latter part go beyond a target code amount. Using-up of an excess code amount to be allocated (the total of differences between a target code amount and each generated code amount) for the simple scenes easy for encoding abruptly decreases code amounts to be allocated to cause picture degradation for, particularly, complex scenes hard for encoding, compared to encoding with fixed bit rate control.
On the other hand, for a moving picture sequence with the former part of complex scenes hard for encoding and the latter part of scenes having average picture complexity, code amounts are allocated for the latter part with reference to the picture complexity of the former part.
This causes allocation of extremely small amounts of code to the latter part of average scenes with picture degradation, thus results in amount of codes generated for the moving picture sequence extremely smaller than a target code amount, with ineffective usage of a storage medium.
This technique is capable of allocation of code amounts in which, when an allocated code amount is smaller than a predetermined code amount to be allocated bav decided on the basis of actual storage capacity of a storage medium, after this, code amount allocation beyond bav is made possible.
This achieves improvement in subjective picture quality for a moving picture sequence with the former part of simple scenes easy for encoding and the latter part of complex scenes hard for encoding.
Contrary to this, for a moving picture sequence with the former part of complex scenes hard for encoding and the latter part of simple scenes easy for encoding, improvement in subjective picture quality for the former part is impossible and an excess amount of codes is generated for the latter part when encoding is complete, with ineffective usage of a storage medium.
A purpose of the present invention is to provide an apparatus and a method of one pass-encoding with variable-bit rate control for achieving real-time encoding and effective code amount allocation with short delay in processing and small scale of circuitry.
Another purpose of the present invention is to provide an apparatus and a method of one pass-encoding with variable-bit rate control for achieving high picture quality of a moving picture sequence with monotonic increase in picture complexity, which is higher than that by encoding with fixed bit rate control, and also achieving effective code amount allocation.
Still another purpose of the present invention is to provide an apparatus and a method of one pass-encoding with variable-bit rate control for achieving effective code amount allocation over the entire moving picture sequence for high picture quality.
The present invention provides an apparatus for encoding input moving pictures with motion-compensated prediction. The apparatus includes: a code amount detector to detect an amount of codes generated for each encoded picture of the input moving pictures; a factor detector to detect an average quantization scale factor of quantization scale factors used for quantizing the pictures of the input moving pictures when encoded; a characteristics detector to detect picture characteristics of at least the input moving pictures; a calculator, responsive to the amount of codes generated for each picture, the average quantization scale factor and the picture characteristics, to calculate complexity of each picture; and a controller responsive to the amount of codes generated for each picture, picture characteristics and the complexity of each picture, to decide an amount of codes to be allocated to a present picture to be encoded, for obtaining a quantization scale factor for the present picture.
Furthermore, the present invention provides an apparatus for encoding input moving pictures with motion-compensated prediction. The apparatus includes: a code amount detector to detect an amount of codes generated for each encoded picture of the input moving pictures; a factor detector to detect an average quantization scale factor of quantization scale factors used for quantizing the pictures of the input moving pictures when encoded; a characteristics detector to detect picture characteristics of at least the input moving pictures; a calculator, responsive to the generated amount of codes and the average quantization scale factor, to calculate complexity of each encoded picture and a present picture to be encoded; a code amount decider to decide a target code amount for a predetermined period, based on the generated amount of codes; and a controller, responsive to the generated amount of codes generated, picture characteristics, complexity of the picture, and target code amount, to decide an amount of codes to be allocated to a present picture to be encoded, for obtaining a quantization scale factor for the present picture.
Moreover, the present invention provides an apparatus for encoding input moving pictures with motion-compensated prediction. The apparatus includes: a code amount detector to detect an amount of codes generated for each encoded picture of the input moving pictures; a factor detector to detect an average quantization scale factor of quantization scale factors used for quantizing the pictures of the input moving pictures when encoded; an amount setter to set a target code amount based on a recording time for recording the input moving pictures; a margin setter to set a margin of the generated amount of codes based on the recording time, the margin being modified based on a difference between the generated amount of codes and the target average code amount; and a controller to decide a code amount to be allocated for a predetermined period by adding the margin and the target average code amount, and obtaining a quantization scale factor for a present picture to be coded based on the code amount to be allocated, the present picture being encoded by using the obtained quantization scale factor when larger than a minimum quantization scale factor set based on the target average code amount.
Furthermore, the present invention provides a method of encoding input moving pictures with motion-compensated prediction. An amount of codes generated for each encoded picture of the input moving pictures is detected. An average quantization scale factor of quantization scale factors used for quantizing the pictures of the input moving pictures when encoded is detected. Picture characteristics of at least the input moving pictures is detected. Complexity of each picture is calculated in response to the amount of codes generated for each picture, the average quantization scale factor and the picture characteristics. An amount of codes to be allocated to a present picture to be encoded is decided in response to the amount of codes generated for each picture, picture characteristics and the complexity of each picture, for obtaining a quantization scale factor for the present picture.
Moreover, the present invention provides a method of encoding input moving pictures with motion-compensated prediction. An mount of codes generated for each encoded picture of the input moving pictures is detected. An average quantization scale factor of quantization scale factors used for quantizing the pictures of the input moving pictures when encoded is detected. Picture characteristics of at least the input moving pictures is detected. Complexity of each encoded picture and a present picture to be encoded are calculated in response to the generated amount of codes and the average quantization scale factor. A target code amount for a predetermined period is decided, based on the generated amount of codes. An amount of codes to be allocated to a present picture to be encoded is decided, in response to the generated amount of codes generated, picture characteristics, complexity of the picture, and target code amount, for obtaining a quantization scale factor for the present picture.
Moreover, the present invention provides a method of encoding input moving pictures with motion-compensated prediction. An amount of codes generated for each encoded picture of the input moving pictures is detected. An average quantization scale factor of quantization scale factors used for quantizing the pictures of the input moving pictures when encoded is detected. A target code amount is set based on a recording time for recording the input moving pictures. A margin of the generated amount of codes is set based on the recording time. The margin is modified based on a difference between the generated amount of codes and the target average code amount. A code amount to be allocated is, decided for a predetermined period by adding the margin and the target average code amount. A quantization scale factor for a present picture to be coded is obtained based on the code amount to be allocated. The present picture is encoded by using the obtained quantization scale factor when larger than a minimum quantization scale factor set based on the target average code amount.